package com.iplant.ams.service;

import com.iplant.ams.service.po.dms.DMSDeviceLedger;
import com.iplant.ams.service.po.dms.fault.DMSFaultBase;
import com.iplant.ams.service.po.dms.scada.alarm.DMSDeviceAlarm;
import com.iplant.ams.service.po.dms.scada.alarm.DMSDeviceAlarmStatistics;
import com.iplant.ams.service.po.dms.scada.conf.DMSDeviceParameter;
import com.iplant.ams.service.po.dms.scada.conf.DMSPosition;
import com.iplant.ams.service.po.dms.maintenance.*;
import com.iplant.ams.service.po.dms.scada.conf.DMSDeviceServer;
import com.iplant.ams.service.po.dms.scada.para.DMSDeviceRealParameter;
import com.iplant.ams.service.po.dms.scada.record.DMSProcessRecord;
import com.iplant.ams.service.po.dms.scada.record.DMSProcessRecordItem;
import com.iplant.ams.service.po.dms.scada.status.DMSDeviceAreaStatus;
import com.iplant.ams.service.po.dms.scada.status.DMSDeviceStatistics;
import com.iplant.ams.service.po.dms.scada.status.DMSDeviceStatus;
import com.iplant.ams.service.po.dms.scada.status.DMSDeviceStatusStatistics;
import com.iplant.base.po.Pagination;
import com.iplant.base.po.ServiceResult;
import com.iplant.base.po.excel.ExcelData;
import com.iplant.basic.service.basicenum.bpm.BPMEventModule;
import com.iplant.basic.service.po.bms.BMSEmployee;

import java.util.Calendar;
import java.util.List;
import java.util.Map;

public interface DMSService {



    ServiceResult<Map<Integer, Map<String, Integer>>> DMS_SelectDeviceStatusTime(BMSEmployee wLoginUser, List<Integer> wID, String wCode, String wName,
                                                                                 List<String> wAssetNoList, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,   int wAreaID,
                                                                                       Calendar wStartTime, Calendar wEndTime);

    ServiceResult<List<DMSDeviceStatus>> DMS_CurrentDeviceStatusList(BMSEmployee wLoginUser, int wDeviceID, String wDeviceNo, String wDeviceName,
                                                                     String wAssetNo, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,   int wAreaID,   int wStatus,   Pagination wPagination);

    ServiceResult<List<DMSDeviceAreaStatus>> DMS_CurrentDeviceStatusStatistics(BMSEmployee wLoginUser, String wName,
                                                                               String wAssetNo, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,  int wAreaID,   int wStatus, Pagination wPagination);


    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatusList(BMSEmployee wLoginUser, String wName,
                                                                    String wAssetNo, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,  int wAreaID,
                                                                    int wActive, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);
    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatus(BMSEmployee wLoginUser, int wID, String wCode,
                                                                String wAssetNo, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatusList(BMSEmployee wLoginUser, List<Integer> wIDList,
                                                                    Calendar wStartTime, Calendar wEndTime, Pagination wPagination);



    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatusDetailList(BMSEmployee wLoginUser, String wName, int wDeviceID,
                                                                          String wAssetNo, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,  int wAreaID,
                                                                          List<Integer> wStatus, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);
    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatusDetail(BMSEmployee wLoginUser, int wDeviceID, String wDeviceNo,
                                                                      String wAssetNo, List<Integer> wStatus, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<List<DMSDeviceStatus>> DMS_SelectDeviceStatusDetailList(BMSEmployee wLoginUser,
                                                                          List<Integer> wDeviceIDList, List<Integer> wStatus, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);



    ServiceResult<List<DMSDeviceAlarm>> DMS_CurrentDeviceAlarmList(BMSEmployee wLoginUser, int wDeviceID, String wDeviceNo, String wAssetNo,
                                                                   int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,  int wAreaID,String wAlarmCode, int wDataGrad,int wPositionID);

    ServiceResult<List<DMSDeviceAlarm>> DMS_CurrentDeviceAlarmList(BMSEmployee wLoginUser, List<Integer> wDeviceIDList,
                                                    String wDeviceNo, String wDeviceName, List<String> wAssetNoList, int wDeviceType, int wModelID,
                                                    int wFactoryID, int wWorkShopID, int wAreaID, String wAlarmCode, int wDataGrad,int wPositionID, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<List<DMSDeviceAlarm>> DMS_SelectDeviceAlarmList(BMSEmployee wLoginUser, String wName,
                                                                  String wAssetNo, int wDeviceType, int wModelID, int wFactoryID, int wWorkShopID,   int wAreaID,
                                                                  String wAlarmCode, int wEventType, int wDataGrad,int wPositionID, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<List<DMSDeviceAlarm>> DMS_SelectDeviceAlarm(BMSEmployee wLoginUser, int wID, String wCode, String wAssetNo,
                                                              String wAlarmCode, int wEventType, int wDataGrad, int wPositionID,Calendar wStartTime, Calendar wEndTime, Pagination wPagination);


    ServiceResult<List<DMSDeviceAlarm>> DMS_SelectDeviceAlarmList(BMSEmployee wLoginUser,
                                                                  List<Integer> wIDList, String wAlarmCode, int wEventType, int wDataGrad, int wPositionID,Calendar wStartTime, Calendar wEndTime, Pagination wPagination);


    ServiceResult<List<DMSDeviceRealParameter>> DMS_SelectDeviceRealParameterList(BMSEmployee wLoginUser, String wName, List<String> wVariableName,

                                                                                  int wAreaID, int wDeviceID,  String wAssetNo,   int wDataType, int wDataClass, int wPositionID);

    ServiceResult<List<DMSDeviceRealParameter>> DMS_SelectDeviceRealParameterListByDeviceID(BMSEmployee wLoginUser, List<Integer> wIDList);

    ServiceResult<List<DMSDeviceRealParameter>> DMS_SelectDeviceRealParameterList(BMSEmployee wLoginUser, List<Integer> wIDList);

    ServiceResult<DMSDeviceRealParameter> DMS_SelectDeviceRealParameter(BMSEmployee wLoginUser, int wID, String wCode);

    ServiceResult<List<DMSDeviceAlarmStatistics>> DMS_SelectDeviceAlarmStatisticsList(BMSEmployee wLoginUser,
                                                                                      int wDeviceID, String wDeviceNo, String wDeviceName, String wAssetNo, int wDeviceType, int wModelID, int wFactoryID,
                                                                                      int wWorkShopID,   int wAreaID,  int wStatus, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);
    ServiceResult<Map<Integer, Map<String, Object>>> DMS_SelectDeviceRealParameterStructList(BMSEmployee wLoginUser, String wName, List<String> wVariableName,

                                            int wAreaID, int wDeviceID,  String wAssetNo,  int wDataType, int wDataClass, int wPositionID);

    ServiceResult<Map<String, Object>> DMS_SelectDeviceCurrentStruct(BMSEmployee wLoginUser, int wDeviceID, String wDeviceNo, String wAssetNo);


    ServiceResult<List<DMSDeviceStatusStatistics>> DMS_SelectDeviceStatusStatisticsList(BMSEmployee wLoginUser,
                          int wDeviceID, String wDeviceNo, String wDeviceName, String wAssetNo, int wDeviceType, int wModelID, int wFactoryID,
                          int wWorkShopID,  int wAreaID, int wStatus, Boolean wIsCombine,   Calendar wStartTime, Calendar wEndTime, Pagination wPagination, int wHasAlarm);


    ServiceResult<List<DMSProcessRecord>> DMS_SelectProcessRecordList(BMSEmployee wLoginUser, int wProductID, int wOrderID,
                                                                      String wOrderNo, String wAssetNo, int wDeviceID, String wDeviceNo, String wWorkpieceNo, int wRecordType, List<Integer> wDataClassList,
                                                                      int wActive, int wStatus, Calendar wStartTime, Calendar wEndTime,
                                                                      int wTechnologyID, Pagination wPagination);

    ServiceResult<List<DMSProcessRecord>> DMS_SelectProcessRecordUploadList(BMSEmployee wLoginUser);

    ServiceResult<Integer> DMS_UpdateProcessRecordUploadStatus(BMSEmployee wLoginUser, List<Integer> wRecordIDList, int wUploadStatus);

    ServiceResult<DMSProcessRecord> DMS_SelectProcessRecord(BMSEmployee wLoginUser, int wID);
    /// <summary>
    /// 获取工件某个记录的最后一条
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wWorkpieceNo"></param>
    /// <param name="wRecordType"></param>
    /// <returns></returns>
    ServiceResult<DMSProcessRecord> DMS_SelectLastProcessRecord(BMSEmployee wLoginUser, String wWorkpieceNo, int wRecordType);
    ServiceResult<List<DMSProcessRecordItem>> DMS_SelectProcessRecordItemList(BMSEmployee wLoginUser, int wRecordID);
    ServiceResult<List<DMSProcessRecordItem>> DMS_SelectProcessRecordItemList(BMSEmployee wLoginUser, int wDeviceID, String wDeviceNo, int wRecordID,
                                                                              int wParameterID, String wParameterNo, int wActive, int wStatus, Calendar wStartTime, Calendar wEndTime, Pagination wPagination);




    ServiceResult<Integer> DMS_SyncDeviceStatus(BMSEmployee wLoginUser, String wAssetNo, int wStatus);
    /// <summary>
    /// 同步设备当前状态
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wDMSDeviceStatusList">当前状态列表</param>
    /// <returns>错误信息</returns>

    ServiceResult<List<String>> DMS_SyncDeviceStatusList(BMSEmployee wLoginUser, List<DMSDeviceStatus> wDMSDeviceStatusList);

    /// <summary>
    /// 填补历史状态 （备用）
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wDMSDeviceStatusList">历史状态列表</param>
    /// <returns>错误信息</returns>
    ServiceResult<List<String>> DMS_SyncDeviceStatusHistoryList(BMSEmployee wLoginUser, List<DMSDeviceStatus> wDMSDeviceStatusList);

    /// <summary>
    /// 关闭设备所有当前报警
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wAssetNo"></param>
    /// <returns></returns>
    ServiceResult<Integer> DMS_CloseDeviceAlarmAll(BMSEmployee wLoginUser, String wAssetNo);

    /// <summary>
    /// 同步设备报警
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wAssetNo"></param>
    /// <param name="wAlarmCode"></param>
    /// <param name="wEventType"></param>
    /// <param name="wIsCode"></param>
    /// <returns></returns>
    ServiceResult<Integer> DMS_SyncDeviceAlarm(BMSEmployee wLoginUser, String wAssetNo, String wAlarmCode, int wEventType, int wIsCode);


    /// <summary>
    /// 同步设备报警 ,并插入不存在的配置
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wAssetNo"></param>
    /// <param name="wAlarmCode"></param>
    /// <returns></returns>
    ServiceResult<DMSDeviceParameter> DMS_SyncDeviceAlarm(BMSEmployee wLoginUser, int wDeviceID, String wAssetNo, String wAlarmCode);


    /// <summary>
    /// 同步设备当前报警
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wDMSDeviceAlarmList">当前报警列表</param>
    /// <returns>错误信息</returns>
    ServiceResult<List<String>> DMS_SyncDeviceAlarmList(BMSEmployee wLoginUser, List<String> wAssetNoList, List<DMSDeviceAlarm> wDMSDeviceAlarmList);

    /// <summary>
    /// 同步设备历史报警（备用）
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wDMSDeviceAlarmList">历史报警列表</param>
    /// <returns>错误信息</returns>
    ServiceResult<List<String>> DMS_SyncDeviceAlarmHistoryList(BMSEmployee wLoginUser, List<DMSDeviceAlarm> wDMSDeviceAlarmList);



    ServiceResult<Integer> DMS_SyncDeviceRealParameter(BMSEmployee wLoginUser, String wAssetNo, String wParameterCode, String wParameterValue);
    /// <summary>
    /// 同步设备参数列表
    /// </summary>
    /// <param name="wLoginUser"></param>
    /// <param name="wDMSDeviceRealParameterList">设备参数列表</param>
    /// <returns>错误信息</returns>
    ServiceResult<List<String>> DMS_SyncDeviceRealParameterList(BMSEmployee wLoginUser, List<DMSDeviceRealParameter> wDMSDeviceRealParameterList);



    ServiceResult<Integer> DMS_SyncProcessRecord(BMSEmployee wLoginUser, String wAssetNo, String wWorkpieceNo, String wOrderNo, String wProductNo, Map<String, DMSProcessRecordItem> wDMSProcessRecordItemDic);

    /// <summary>
    /// 同步设备加工过程数据
    /// </summary>
    /// <param name="wBMSEmployee"></param>
    /// <param name="wDMSProcessRecordList">加工过程数据列表</param>
    /// <returns>错误信息</returns>
    ServiceResult<List<String>> DMS_SyncProcessRecordList(BMSEmployee wBMSEmployee, List<DMSProcessRecord> wDMSProcessRecordList);



    ServiceResult<List<DMSDeviceStatistics>> DMS_SelectDeviceStatusDetailStatisticsTime(BMSEmployee wLoginUser, int wLineID, List<Integer> wDeviceIDList, String wAssetNo, int wStatType,
                                                                                        Calendar wStartTime, Calendar wEndTime);


    ServiceResult< List<Map<String, Object>>> DMS_SelectProcessRecordParams(BMSEmployee wLoginUser, String wDeviceCode, Calendar wStartTime, Calendar wEndTime);

    ServiceResult<Integer> DMS_InitDeviceTable(BMSEmployee wLoginUser);
}
